package com.kzn.util;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.springframework.beans.factory.annotation.Value;

import java.util.Collections;

/**
 * @author sorclown
 * @date 2022/2/2
 */
public class MybatisPlusGenerator {




    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/video-dataset-crowdsourcing?serverTimeZone=UTC", "root", "rootroot")
                .globalConfig(builder -> {
                    builder.author("sorclown") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("/Users/kezenan/Downloads"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com") // 设置父包名
                            .moduleName("kzn") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "/Users/kezenan/Downloads/com/kzn/mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("admin") // 设置需要生成的表名
                            .addInclude("publisher")
                            .addInclude("crowd")
                            .addInclude("rewardPoints")
                            .addInclude("project")
                            .addInclude("roughTask")
                            .addInclude("detailedTask");

//                            .addTablePrefix("t_", "c_"); // 设置过滤表前缀
                })
                // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();

    }
}
